<?php

namespace app\servercomment\service\comment;
use app\manage\service\ApiBase;

/**
 * @author:      李颖
 * @DateTime:    2017-06-13 14:18:14
 * @Description: 评论
 */

class Comment extends ApiBase
{
	
	protected $commentLogic = 'app\servercomment\logic\Comment';
    protected $commentValidate = 'app\servercomment\validate\Comment';
    protected $addFields = ['user_id'=>0,'obj_id'=>0,'obj_content'=>'','orther_info'=>'','type'=>' ','content'=>' '];

    /*某用户评论某文章、商品等*/
    public function addComment(): array 
    {
    	$data = $this->receiveData($this->addFields);
    	$data['avg_score'] = 0;

    	if(!is_array($data['orther_info']['score']) || count($data['orther_info']['score']) == 0){
    		return verify_err(null, '请进行评分');
    	}

		return $this->stepRun($data, 'addComment');
    }

    /*管理员删除某个评论*/
    public function delOneComment(): array 
    {
    	$data = $this->receiveData(['id'=>0]);
    	return $this->stepRun($data, 'delBatchComment', 'checkId');
    }

    /*管理员批量删除评论*/
    public function delBatchComment(): array 
    {
    	$data = $this->receiveData(['id'=>[]]);
    	return $this->stepRun($data, 'delBatchComment', 'checkIds');
    }

    /*顶某个评论*/
    public function topComment(): array 
    {
        $data = $this->receiveData(['id'=>0]);
        return $this->stepRun($data, 'topComment', 'checkId');
    }

    /*踩某个评论*/
    public function treadComment(): array 
    {
        $data = $this->receiveData(['id'=>0]);
        return $this->stepRun($data, 'treadComment', 'checkId');
    }

    /*获取某篇文章/商品的所有评论*/
    public function comments(): array 
    {
        $data = $this->receiveData(['obj_id'=>0,'page'=>1,'listRows'=>15]);
        return $this->stepRun($data, 'comments');
    }

    /*某个用户的所有评论*/
    public function oneUserComments(): array 
    {
        $data = $this->receiveData(['user_id'=>0,'page'=>1,'listRows'=>15]);
        return $this->stepRun($data, 'comments');
    }

    /*所有用户的评论*/
    public function allComments(): array 
    {
        $data = $this->receiveData(['page'=>1,'listRows'=>15]);
        return $this->stepRun($data, 'comments');
    }

    
 


    
    
}






